package com.yang.Inet.test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class SocketDemo {
	public static void main(String[] args) throws UnknownHostException, IOException {

		// 本地客户端
		Socket socket = new Socket("192.168.30.137", 10001);
		OutputStream out = socket.getOutputStream();
		// 直接发送数据
		out.write("哈哈 TCPTest".getBytes());

		InputStream in = socket.getInputStream();
		byte[] buf = new byte[1024];
		int read = in.read(buf);
		String text = new String(buf, 0, read);
		System.out.println("服务端返回数据    " + text);
		socket.close();

	}
}
